<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>设置cookie</button><button>获取cookie</button><button>删除cookie</button>
    <script src="./js/jquery-1.9.0.min.js"></script>
    <script src="./js/jquery.cookie.js"></script>
    <script>
        var aBtn = document.querySelectorAll('button');
        //设置
        aBtn[0].onclick = function () {
            $.cookie('user', '天地一号');// 没有设置过期时间，过期时间是 session ,浏览器关闭后就没有了
            $.cookie('pwd', '111111', { expires: 4 });//expires 过期时间 4 天数  ，需要cookie 过期后才会失效
        }
        //获取
        aBtn[1].onclick = function () {
            console.log($.cookie('user'));
            console.dir(document);

        }
        //删除
        aBtn[2].onclick = function () {
            $.removeCookie("user");

        }
    </script>
</body>

</html>